package com.tongtong.controller.user.service;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tongtong.controller.email.entity.TtEmailConfig;
import com.tongtong.controller.email.mapper.TtEmailConfigMapper;
import com.tongtong.controller.user.entity.TtUser;
import com.tongtong.controller.user.mapper.TtUserMapper;
import com.tongtong.controller.user.req.UserReq;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
public class TtUserService extends ServiceImpl<TtUserMapper, TtUser> {

    public void saveUser(UserReq.regist regist) {
        TtUser ttUser = BeanUtil.copyProperties(regist, TtUser.class);
        baseMapper.insert(ttUser);
    }

    public TtUser queryUserByAccount(String account) {
        LambdaUpdateWrapper<TtUser> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(TtUser::getEmail, account);
        TtUser ttUser = baseMapper.selectOne(wrapper);
        return ttUser;
    }
}
